<template>
	<view class="" style="width: 100vw;height: 100vh" :style="{'background':kbackgroundColor2}">
		<hx-navbar title="收银台" :back="true" :fixed="false" :color="knavTitleColor"
			:style="{background:kbackgroundColor2}" barPlaceholder="hidden" transparent="auto"></hx-navbar>
		<view class="content" :style="{color:knormalColor}">
			<view class="pay"> 支付金额 </view>
			<view class="payNum"> ￥{{payNum|fp}} </view>
			<view class="way">
				<view class=""> 支付方式 </view>
				<view class=""> 钱包余额 </view>
			</view>
			<view class="m-t-40">
				<view class="btn" :style="{background:kbuttonBgColor}" @tap="go_pay()">确认支付</view>
			</view>
			<!-- 未设置密码 -->
			<uni-popup ref="bindingDialog" type="center" :maskBackgroundColor="'rgba(0,0,0,0.5)'" :isMaskClick="false">
				<view class="store-view store-border-all tips-padding"
					:style="{'background':kbackgroundColor,color:knormalColor}"
					:class="[{'alert-border-black alert-border-shadow-black':ktheme =='black'},{'alert-border-purple':ktheme =='purple'}]">
					<text class="popup-title">提示</text>
					<text class="popup-subtitle">为了您的账号安全，请您设置支付密码后
						再进行操作!</text>
					<view class="tips-bottom">
						<view class="tips-button"
							:class="[{'tips-cancel-bg-black':ktheme =='black'},{'tips-cancel-bg-white':ktheme =='purple'}]"
							@click="bindingClose()">关闭</view>
						<view class="tips-button" :style="{background:kbuttonBgColor}" @click="bindingCheck()">去设置
						</view>
					</view>
				</view>
			</uni-popup>
			<paypass ref="passbox" @confirm="set_done"></paypass>
		</view>
	</view>
</template>

<script>
	import paypass from '@/components/pay_pass/pay_pass.vue'
	export default {
		data() {
			return {
				payNum: '22',
				nftType: "",
				payWay: "",
				nftIdList: [],
				orderId: "",
				secondPassword: "",
				iftype: 1 ,//批量 2单个
                tableData:[]
			}
		},
		components: {
			paypass
		},
		onLoad(options) {
			this.nftType = options.nftType
			this.payNum = options.payNum
			// this.nftIdList = options.nftIdList
			this.orderId = options.orderId
			this.iftype = options.iftype
			if(options.cid==1){
				 let ordersString = decodeURIComponent(options.nftIdList);
				this.nftIdList= JSON.parse(ordersString);
			}
			// 勾选卢克
		
	 

		},
		onPullDownRefresh() {
			setTimeout(function() {
				uni.stopPullDownRefresh()
			}, 1000)
		},
		methods: {
			bindingCheck() {
				this.$refs.bindingDialog.close()
				uni.navigateTo({
					url: '/pages/user/settings/pay_pass/pay_pass'
				})
			},
			bindingClose() {
				this.$refs.bindingDialog.close()
			},
			set_done(pass) {
				let body = {
					orderId: this.orderId,
					type: this.nftType,
					payWay: 7,
					secondPassword: pass,
					nftIdList:this.nftIdList
				};
				 //批量 2单个
				if (this.iftype == 1) {
					this.$api.payHfOrderBatch(body, res => {
						if (res.status) {
							if (res.data == '余额不足') {
								this.$common.errorToShow('余额不足')
								setTimeout(function() {
									uni.navigateTo({
										url: '/pages/user/wallet_system/wallet_system'
									})
								}, 3000)
							} else {
								uni.redirectTo({
									url: '/pages/payment/result_system?payNum=' + this.payNum
								})
							}
						} else {
							this.$common.errorToShow(res.message)
						}
					});
				} else {
					this.$api.payHfOrder(body, res => {
						if (res.status) {
							if (res.data == '余额不足') {
								this.$common.errorToShow('余额不足')
								setTimeout(function() {
									uni.navigateTo({
										url: '/pages/user/wallet_system/wallet_system'
									})
								}, 3000)
							} else {
								uni.redirectTo({
									url: '/pages/payment/result_system?payNum=' + this.payNum+'&ai=NoAi'
								})
							}
						} else {
							this.$common.errorToShow(res.message)
						}
					});


				}


			},
			go_pay() {
				this.$api.checkSecondPassword({}, res => {
					if (res.status) {
						let data = res.data
						if (data.secondPassword) {
							this.$refs.passbox.open();
						} else {
							this.$refs.bindingDialog.open()
						}
					} else {
						this.$common.errorToShow('网络异常');
					}
				})

			}

		}
	}
</script>

<style scoped lang="scss">
	.content {
		width: 100%;
		padding: 0 40rpx;
		text-align: center;
		margin-top: 40rpx;
	}

	.pay {
		font-weight: 400;
		font-size: 24rpx;
		line-height: 40rpx;

	}

	.payNum {
		font-weight: bold;
		font-size: 48rpx;
		margin-top: 40rpx;
		line-height: 40rpx;
	}

	.way {
		margin-top: 40rpx;
		width: 660rpx;
		display: flex;
		justify-content: space-between;
	}

	.btn {
		width: 560rpx;
		height: 80rpx;
		border-radius: 100rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 32rpx;
		color: #fff;
		font-weight: 400;
		margin: 50rpx auto;
	}
</style>